app.controller('successCtrl',['$scope','$location','$rootScope',function($scope,$location,$rootScope){
    $scope.task={
        description:''
    };

    $scope.taskList=[];

    $scope.exit = function(){
        $location.path('/login')
    };

    $scope.editTask = function (task){
        task.isEditing=true;
        task.tempTaskName = task.description;
    };

    $scope.deleteTask = function(index){
        $scope.taskList.splice(index,1)
    };

    $scope.cancel = function(task){
        task.isEditing = false;
    };

    $scope.save = function (task){
       task.description = task.tempTaskName;
       task.isEditing = false;
    };

    $scope.addTask=function(){
        var task = angular.copy($scope.task);
        task.checked = false;
        task.status = 'InProgress';
        $scope.taskList.push(task);
        $scope.task.description = '';
    };
}]);
